package com.yuhao.common.strcount.log_20191219;

import com.google.common.collect.Maps;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Main {

    public static final String strReg = "rows";

    public static final String strReg1 = "行";

    public static void main(String[] args) {
         // 获取日志路径下所有后缀为.log的文件
        List<LogFile> list = LogResolvUtil.getFileNames();
        // 解析文件获取size和rows
        List<LogFile> list1 = LogResolvUtil.logResolv(list, strReg1);
        // 结果汇总
        Map<String, String> map = LogResolvUtil.countInfo(list);
        // 输出单一文件结果
        list1.forEach(System.out::println);
        System.out.println("汇总如下：");
        // 输出汇总结果
        map.forEach((key, value) -> System.out.println(key + "," + value + "MB"));
        List<String> strList = list1.stream().map(e -> e.getTablePartitionName().split("_")[2].split("\\.")[0]).distinct().collect(Collectors.toList());
        LogResolvUtil.outToFile(strList, list1.stream().map(e -> e.getTablePartitionName()).collect(Collectors.toList()));
    }
}